import 'dart:convert';

import 'package:dio/dio.dart';
import 'http_response.dart';
import 'http_transformer.dart';

class VersionHttpTransformer extends HttpTransformer {
  @override
  HttpResponse<T> parse<T>(Response response) {
    if (response.data != null) {
      return HttpResponse.success(response.data);
    } else {
      return HttpResponse.failure(
          errorMsg: response.data["result"]["message"], errorCode: response.data["result"]["code"]);
    }
  }

  static VersionHttpTransformer _instance = VersionHttpTransformer._internal();

  VersionHttpTransformer._internal();

  factory VersionHttpTransformer.getInstance() => _instance;
}
